<template>
    <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }" @submit="handleSubmit">
        <a-form-item label="姓名">
            <a-input v-decorator="['name', { rules: [{ required: true, message: 'Please input your name!' }] }]" />
        </a-form-item>
        <a-form-item label="电话">
            <a-input v-decorator="['tel', { rules: [{ required: true, message: 'Please input your tel!' }] }]" />
        </a-form-item>
        <a-form-item :wrapper-col="{ span: 12, offset: 5 }">
            <a-button type="primary" html-type="submit">
                提交
            </a-button>
        </a-form-item>
    </a-form>
</template>

<script>
import { mapState } from 'vuex';
export default {
    inject: ['reload'],
    data() {
        return {
            formLayout: 'horizontal',
            form: this.$form.createForm(this, { name: 'coordinated' }),
        };
    },
    methods: {
        handleSubmit(e) {
            e.preventDefault();
            this.form.validateFields((err, values) => {
                if (!err) {
                    this.$store.dispatch('adduser', values)
                    console.log('Received values of form: ', values);
                   
                }
            });
            this.$store.commit('isShow')
            this.$store.dispatch('dList')
            this.reload();
        }
        
    },
    computed: {
      
        ...mapState({
            duserlist: (state) => {
                return state.userinfo.duserlist;
            },

        }),
       

    },
};
</script>